import {deleteAction, getAction, postAction, downFile, getFileAccessHttpUrl} from '@/api/request'

export const application12_create = {

    data() {
        return {
            url: {
                tab12Infor: "/api/ac/subsistence/ss02017Service/getTab12Infor",
                tab12Submit: "/api/ac/subsistence/ss02017Service/updateTab12Submit",
                getMemberList: "/api/ac/subsistence/ss12001ChangeService/getMemberList"
            },
            memberList: [],
            Loading: false,
            familyInfo: {},
            submitDisabled: true,
            disabled: true,
            information: "",
            memberInformation: "",
            ruleValidate: {
                ssca0044: [
                    {required: true, message: '家庭月基础收入金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0045: [
                    {required: true, message: '家庭月赡抚养费金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0046: [
                    {required: true, message: '家庭月财产收入金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0047: [
                    {required: true, message: '家庭月基础支出金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0049: [
                    {required: true, message: '家庭月总收入金额不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0051: [
                    {required: true, message: '家庭人口数不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0042: [
                    {required: true, message: '保障标准不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0052: [
                    {required: true, message: '保障人口数不能为空!', trigger: 'blur', type: "number"}
                ],
                ssca0025: [
                    {required: true, message: '分类救助上浮总金额不能为空！', trigger: 'blur', type: "number"}
                ],
                ssca0004: [
                    {required: true, message: '差额保障金额不能为空！', trigger: 'blur', type: "number"}
                ],
                ssca0026: [
                    {required: true, message: '总保障金额不能为空！', trigger: 'blur', type: "number"}
                ],
                ssca0065: [
                    {required: true, message: '高龄补贴总金额不能为空！', trigger: 'blur', type: "number"}
                ],
                ssca0013: [
                    {required: true, message: '请选择致贫原因！', trigger: 'change'}
                ],
                ssca0009: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'change'}
                ],
                ssca0082: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'change'}
                ],
                ssca0010: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'blur'}
                ],
                ssca0083: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'blur'}
                ],
                ssca0011: [
                    {required: true, message: '请前往【低保救助业务办理】【银行帐户信息维护】补全信息！', trigger: 'blur'}
                ],
                ssca0089: [
                    {required: true, message: '请选择是否入户调查、民主评议、审批公示！', trigger: 'change'}
                ],
                ssca0090: [
                    {required: true, message: '请选择是否进行经济核查！', trigger: 'blur'}
                ],
                yjab0009:[
                    {required: true, message: '预警处置原因不能为空！', trigger: 'blur'}
                ],
                yjab0008: [
                    {required: true, message: '处置时间不能为空！', trigger: 'change', pattern: /.+/}
                ],
            },

        }
    },
    methods: {
        //提交申请
        prevStep() {
            this.$emit('prevStep')
        },
        nextStep() {
            this.formValidate.oldBpmStatus = this.bpmStatus;
            this.formValidate.oldSs12001Id = this.$parent.familyInfo.oldSs12001Id;
            if (this.formValidate.ssca0090 == '0' && this.isValidate) {
                //如果选【否】，需要进行确认操作，确认信息提示本次变更家庭成员结构发生了哪些变化
                this.$Modal.confirm({
                    title: this.validateMessage,
                    onOk: () => {
                        this.tab12Submit();
                    }
                })
            } else {
                this.tab12Submit();
            }

        },
        printSs00011() {
            this.$refs.printModal.edit(this.$parent.familyInfo.ss12001Id);
        },
        changeSubmit() {
            this.submitDisabled = false
        },
        autoChangeSubmit(){
            let yjab0012=this.$parent.familyInfo.yjab0012
            if(yjab0012=='01'||yjab0012=='02'||yjab0012=='04'){
                this.submitDisabled = false
            }else{
                this.submitDisabled = true
            }
        },
        changeSsca0082() {
            this.formValidate.ssca0083 = "";
            this.formValidate.ssca0010 = "";
        },
        changeSsca0010(obj) {
            this.$set(this.formValidate, "ssca0083", obj);
        },
        tab12Submit() {
            this.Loading = true;
            var that = this;
            this.formValidate.ss02017Id=that.$parent.familyInfo.ss02017Id
            this.$refs['formValidate'].validate((valid) => {
                if (valid) {
                    postAction(that.url.tab12Submit, this.formValidate).then((res) => {
                        if (res.data.errcode == 0) {
                            that.$Message.success("提交申请成功！");
                            that.$emit('finish');
                        } else {
                            that.$Message.error(res.data.errmsg);
                        }
                    }).finally(() => {
                        that.Loading = false;
                    });
                } else {
                    that.Loading = false;
                }
            })
        },
        getFamilyInfor() {
            this.familyInfo = this.$parent.familyInfo;
        },
        getTab12Infor() {
            var that = this;
            let yjab0012=that.$parent.familyInfo.yjab0012;
            postAction(that.url.tab12Infor, {
                ss12001Id: that.$parent.familyInfo.ss12001Id,
                oldSs12001Id: that.$parent.familyInfo.oldSs12001Id,
                ss02017Id: that.$parent.familyInfo.ss02017Id,
                yjab0012: yjab0012,
                ssca0012: that.$parent.familyInfo.ssca0012,
            }).then((res) => {
                if (res.data.errcode == 0) {
                    that.formValidate = res.data.data.ss12001;
                    //验证是否新增18周岁以上人员
                    that.validate18Age = res.data.data.validate18Age;
                    that.validateMessage = res.data.data.validateMessage;
                    if (that.validate18Age == true) {
                        //满足条件则 必须进行经济核查、控件不可用
                        that.formValidate.ssca0090 = '1';
                        that.disabled0090 = true;
                    } else {
                        that.disabled0090 = false;
                    }
                    that.label=that.formValidate.ssca0002=='203'?'是否入户调查：':'是否入户调查、民主评议、审批公示:';

                    if (that.formValidate.ssca0002 == '100' || that.formValidate.ssca0002 == '200' || that.formValidate.ssca0002 == '102' || that.formValidate.ssca0002 == '202') {
                        that.text = "总保障金额=差额保障金额+分类救助上浮总金额，不包括高龄补贴总金额";
                    } else {
                        that.text = "总保障金额=保障人口数*保障标准，不包括高龄补贴总金额";
                    }
                    that.information = res.data.data.information;
                    that.memberInformation = res.data.data.memberInformation;

                    //预警处置信息
                    that.$set(that.formValidate,'yjab0001',res.data.data.yjab0001);
                    that.$set(that.formValidate,'yjab0012',res.data.data.yjab0012);
                    that.$set(that.formValidate,'yjab0002',res.data.data.yjab0002);
                    that.$set(that.formValidate,'yjab0004',res.data.data.yjab0004);
                    that.$set(that.formValidate,'yjab0005',res.data.data.yjab0005);
                    that.$set(that.formValidate,'yjab0017',res.data.data.yjab0017);
                    that.$set(that.formValidate,'yjab0007',res.data.data.yjab0007);
                    that.$set(that.formValidate,'yjab0008',res.data.data.yjab0008);
                    that.$set(that.formValidate,'yjab0009',res.data.data.yjab0009);

                    if (that.formValidate.yjab0005) {
                        that.formValidate.yjab0005 = this.DateFormat(that.formValidate.yjab0005, 'YYYY-MM-DD');
                    }
                    if (that.formValidate.yjab0008) {
                        that.formValidate.yjab0008 = this.DateFormat(that.formValidate.yjab0008, 'YYYY-MM-DD');
                    }else{
                        that.formValidate.yjab0008 = this.DateFormat(new Date(), 'YYYY-MM-DD');
                    }
                    //已处置、维持现状、停救不进行经济核查、入户调查等
                    if(yjab0012=='01'||yjab0012=='02'||yjab0012=='04'){
                        that.formValidate.ssca0089='0';
                        that.formValidate.ssca0090='0';
                        that.disabled0089 = true;
                        that.disabled0090 = true;
                    }
                    //本户其他预警数据数量
                    that.otherWarnCount=res.data.data.otherWarnCount;

                    console.log(that.formValidate);
                } else {
                    that.$Message.error(res.data.errmsg);
                }
            }).finally(() => {
                that.Loading = false;
            });
        },
        //获取家庭成员信息
        getMemberList() {
            var that = this;
            postAction(that.url.getMemberList, {azcp0500: this.$parent.familyInfo.ss17001Id}).then((res) => {
                if (res.data.errcode == 0) {
                    that.memberList = res.data.data;
                } else {
                    that.$Message.error(res.data.errmsg);
                }
            }).finally(() => {
                that.Loading = false;
            });
        },
        showOthers(){
            this.$refs.otherWarnModal.edit(this.$parent.familyInfo.ss02017Id,this.$parent.familyInfo.yjab0015);
        }
    }
}
